package com.demo;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.HashMap;
import java.util.Map;

@SpringBootApplication
public class C2Application {
    public static void main(String[] args) {
        Map map = new HashMap();
        map.put("name", "map");
        ConfigurableApplicationContext applicationContext=new SpringApplicationBuilder(C2Application.class).properties(map).run(args);
        System.out.println("------------打印PropertySources中配置的顺序");
        applicationContext.getEnvironment().getPropertySources().forEach(f->{
            System.out.println(f.getName());
        });
        /**
         * 输出内容（前面的配置会覆盖后面的配置）：
         server.ports
         configurationProperties
         servletConfigInitParams
         servletContextInitParams
         systemProperties
         systemEnvironment
         random
         applicationConfig: [classpath:/application-dev.properties]
         applicationConfig: [classpath:/config/application-redis.properties]
         applicationConfig: [classpath:/config/application.properties]
         applicationConfig: [classpath:/application.properties]
         applicationConfig: [classpath:/application.yml]
         defaultProperties
         */
    }
}
